package org.agilelang.editor.tool;

/*
 AgileLang - A fourth generation language(http://www.agilelang.org).

 Copyright (C) 2013 Roderick Cusirramos (roderick20@hotmail.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class I18n {
    
    private static ResourceBundle i18n;

    public static void init() {
        try {
            Locale deLocale = new Locale("en", "EU");
            i18n = ResourceBundle.getBundle("org.agilelang.editor.resources.messages", deLocale);
            Log.Instance().info("I18n", "I18n", "Load resource i18n");
        } catch (java.lang.NullPointerException e) {
            Log.Instance().error("I18n", "I18n", e.toString());
        }
    }

    public static String _(String s) {
        try {
            Log.Instance().error("I18n", "_()", "get words");
            return i18n.getString(s);
        } catch (MissingResourceException e) {
            //Log.Instance().error("I18n", "_()",s +" - "+ e.toString());
            return s;
        }
    }
}
